package bas.gps_fiets;

import java.util.ArrayList;
import team2.gbike.R;
import team2.gbike.location.GPSStore;
import team2.gbike.map.AndroidGoogleMapsActivity;

import bas.gps_fiets.RouteSelector;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

public class RouteSelector extends Activity {

	static public ArrayList<String> listStops;
	static public String text;

	Button bShowRoute;
	//Button bDamsquareinfo;
	//Button bAnneFrankMuseuminfo;
	//Button bRijksMuseuminfo;
	//Button bCentralStationinfo;
	//Button bFlowerMarket;


	CheckBox cbDamSquare;
	CheckBox cbAnneFrankMuseum;
	CheckBox cbRijksMuseum;
	CheckBox cbCentralStation;
	CheckBox cbFlowerMarket;
	CheckBox cbStedelijk, cbVanGogh,cbHermitage,cbScheepvaart, cbOudeKerk, cbVondelpark, cbLeidseplein, cbSpui, cbAmsterdamseBos;
	
	public TextView statusGPS = null,messageGPS = null;
	public ProgressBar progressGPS = null;
	
	OnClickListener checkBoxListener;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		GPSStore.setSelectionScreen(this);

		bShowRoute = 			(Button) (findViewById(R.id.button1));
			
		cbDamSquare = 			(CheckBox) (findViewById(R.id.checkBox1));
		cbAnneFrankMuseum = 	(CheckBox) (findViewById(R.id.checkBox2));
		cbRijksMuseum = 		(CheckBox) (findViewById(R.id.checkBox3));
		cbCentralStation = 		(CheckBox) (findViewById(R.id.checkBox4));
		cbFlowerMarket =		(CheckBox) (findViewById(R.id.checkBox5));
		
		cbAmsterdamseBos =		(CheckBox) (findViewById(R.id.CheckBox06));
		cbStedelijk =		(CheckBox) (findViewById(R.id.CheckBox03));
		cbVanGogh =		(CheckBox) (findViewById(R.id.CheckBox02));
		cbHermitage =		(CheckBox) (findViewById(R.id.CheckBox09));
		cbScheepvaart =		(CheckBox) (findViewById(R.id.CheckBox01));
		cbOudeKerk =		(CheckBox) (findViewById(R.id.CheckBox04));
		cbVondelpark =		(CheckBox) (findViewById(R.id.CheckBox05));
		cbLeidseplein =		(CheckBox) (findViewById(R.id.CheckBox07));
		cbSpui =		(CheckBox) (findViewById(R.id.CheckBox08));
		
		statusGPS = 			(TextView) 		(findViewById(R.id.textView2));
		messageGPS = 			(TextView) 		(findViewById(R.id.textView3));

		progressGPS = 			(ProgressBar)	(findViewById(R.id.progressBar1));	
		statusGPS.setText("Retrieving GPS location");
		messageGPS.setText("It can take some minutes on open sky");
		
		bShowRoute.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				ArrayList<String> list = new ArrayList<String>();
				if (cbCentralStation.isChecked()) {
					list.add("Central Station");
				}
				if (cbRijksMuseum.isChecked()) {
					list.add("Rijksmuseum");
				}
				if (cbStedelijk.isChecked()) {
					list.add("Stedelijk");
				}
				if (cbVanGogh.isChecked()) {
					list.add("Van Gogh");
				}
				if (cbHermitage.isChecked()) {
					list.add("Hermitage");
				}
				if (cbScheepvaart.isChecked()) {
					list.add("Scheepvaart");
				}
				if (cbAnneFrankMuseum.isChecked()) {
					list.add("Anne frank museum");
				}
				if (cbDamSquare.isChecked()) {
					list.add("Damsquare");
				}
				if (cbOudeKerk.isChecked()) {
					list.add("Oude Kerk");
				}
				if (cbFlowerMarket.isChecked()){
					list.add("Flower Market");
				}
				if (cbVondelpark.isChecked()) {
					list.add("Vondelpark");
				}
				if (cbLeidseplein.isChecked()) {
					list.add("Leidseplein");
				}
				if (cbSpui.isChecked()) {
					list.add("Spui");
				}
				if (cbAmsterdamseBos.isChecked()) {
					list.add("Amsterdamse Bos");
				}
				if(list.size()<=10){
					RouteSelector.listStops = list;
					if(list.size()>0){
						Intent i = new Intent(getApplicationContext(), AndroidGoogleMapsActivity.class);
						startActivity(i);
						
					}
				} else {
					Toast.makeText(v.getContext(), "Max 10 places per route!",Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		/*bDamsquareinfo.setOnClickListener		(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(RouteSelector.this, AnneFrankMuseumInfo.class));
			}
		});
		bAnneFrankMuseuminfo.setOnClickListener	(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(RouteSelector.this, AnneFrankMuseumInfo.class));
			}
		});
		bRijksMuseuminfo.setOnClickListener		(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(RouteSelector.this, AnneFrankMuseumInfo.class));
				
			}
		});
		bCentralStationinfo.setOnClickListener	(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(RouteSelector.this, AnneFrankMuseumInfo.class));
				
			}
		});  
		bFlowerMarket.setOnClickListener		(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(RouteSelector.this, AnneFrankMuseumInfo.class));	
				
			}
		});*/
	}
	
	boolean D = true;
	String TAG = "Excp";
	@Override
	public synchronized void onPause() { 
		super.onPause();
		if (D)
			Log.e(TAG, "- ON PAUSE -");
	}

	@Override
	public void onStop() {
		super.onStop();
		if (D)
			Log.e(TAG, "-- ON STOP --");
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		
		if (D)
			Log.e(TAG, "--- ON DESTROY ---");
	}

	@Override
	public synchronized void onResume() {
		super.onResume();
		if (D)
			Log.e(TAG, "+ ON RESUME +");
	}

	

}
